<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改车辆-信息')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-info-edit" th:object="${carInfo}">
            <input name="carInfoId" th:field="*{carInfoId}" type="hidden">
            <input name="carId" th:field="*{carId}" type="hidden">
            <input name="menuId" th:field="*{menuId}" type="hidden">
            <input name="configType" th:field="*{configType}" type="hidden">
            <input id="car_info" name="info" th:field="*{info}" type="hidden">
            <div class="form-group" th:if="${carInfo.carInfoId!=null}">
                <label class="col-sm-2 control-label">图片</label>
                <div class="col-sm-10" th:include="system/common/file_upload :: multiple_img(_file_id='multipleFile',_file_type='img',_file_list=${@file.getFiles(carInfo.carId,carInfo.configType)})"/>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">整车尺寸参数（单位mm/L）</h3>
                </div>
                <div class="panel-body">
                    <span class="form-horizontal" role="form">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">长：</label>
                            <div class="col-sm-2">
                                <input name="infoMap.length" th:field="*{infoMap.length}" class="form-control" type="text"/>
                            </div>
                            <label class="col-sm-2 control-label">高：</label>
                            <div class="col-sm-2">
                                <input name="infoMap.height" th:field="*{infoMap.height}" class="form-control" type="text"/>
                            </div>
                            <label class="col-sm-2 control-label">宽：</label>
                            <div class="col-sm-2">
                                <input name="infoMap.width" th:field="*{infoMap.width}" class="form-control" type="text"/>
                            </div>
                            <label class="col-sm-2 control-label">无镜宽度：</label>
                            <div class="col-sm-2">
                                <input name="infoMap.withoutMirrorWidth" th:field="*{infoMap.withoutMirrorWidth}" class="form-control" type="text"/>
                            </div>
                            <label class="col-sm-2 control-label">轴距：</label>
                            <div class="col-sm-2">
                                <input name="infoMap.wheelbase" th:field="*{infoMap.wheelbase}" class="form-control" type="text"/>
                            </div>
                            <label class="col-sm-2 control-label">前轮距：</label>
                            <div class="col-sm-2">
                                <input name="infoMap.frontWheel" th:field="*{infoMap.frontWheel}" class="form-control" type="text"/>
                            </div>
                            <label class="col-sm-2 control-label">后轮距：</label>
                            <div class="col-sm-2">
                                <input name="infoMap.rearWheel" th:field="*{infoMap.rearWheel}" class="form-control" type="text"/>
                            </div>
                        </div>
                    </span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label"></label>
                <div class="col-sm-8"><button type="button" class="btn btn-success" onclick="submitHandler()">上传</button></div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/car/info";
        $("#form-info-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                let json=$('#form-info-edit').serializeJson();
                console.log(json)
                $('#car_info').val(JSON.stringify(json.infoMap)||'{}');
                let serialize = $('#form-info-edit').serialize();
                console.log(serialize)
                // console.log(JSON.stringify($('#form-info-edit').serializeJson()))
                // return;
                $.operate.save(prefix + "/edit?_="+Math.random(), serialize);
            }
        }
        $(function (){
            multipleFile_manager.init({busId: [[${carInfo.carId}]], busType: [[${carInfo.configType}]], fileType: 'img'});
        });
    </script>
</body>
</html>